window.addEvent('domready',function(){
	//console.log(window);
	//console.log(Window);
	//console.log(document);
	//console.log(Document.id('kx_gallery_inline', null, document));
	//console.log(document.getElement('#kx_gallery_inline'));
	//console.log(document.getElementById('kx_gallery_inline'));
	//console.log(document.id('kx_gallery_inline'));
	//console.log(window.getElement('kx_gallery_inline'));
	
	//console.log(window.$('kx_gallery_inline'));
	
	var galleryPreview = $('kx_gallery_inline');
	//console.log(galleryPreview);
	//galleryPreview = new Element();
	//console.log(galleryPreview);
	var galleries = galleryPreview.getChildren('.kx_gallery');
	
	// dodaj nawigację
	galleries.each(function(item, idx) {
		var prev = new Element('a',{
			id:'item-prev'+idx,
			'class': 'kx_action kx_action_prev_item',
			'html': ' &laquo; Poprzedni album'
		});
		var next = new Element('a',{
			id:'item-next'+idx,
			'class': 'kx_action kx_action_next_item',
			'html': 'Następny album &raquo;'
		});

//		var wrapper = new Element('div', {'class':'carusel-container'});
//		item.getElement('.kx_gallery_album').adopt(wrapper,'top');

		item.getElement('.kx_gallery_album').addClass('carusel-container');
		
		next.inject(item.getElement('.kx_title'),'after');
		prev.inject(item.getElement('.kx_title'),'after');

		var nS2 = new noobSlide({
			box: item.getElement('.kx_gallery_album'),
			// IE 6 & 7
			items: (Browser.Engine.trident && Browser.Engine.version <= 5) ? item.getElements('img') : item.getElements('img').reflect(),
			size: 200,
			autoPlay: false,
			interval: 5000,
			addButtons: {
				previous: prev,
				next: next
			}
		})
	});
});